﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;

namespace ScaffoldIt
{
    using System.Windows.Forms;

    [Guid("9abc91f6-6c8e-44b1-9c90-2d70cb4eac90")]
    public class ScaffoldItToolWindow : ToolWindowPane
    {
        private FormScaffoldItConfigWrapper _control;

        /// <summary>
        /// Standard constructor for the tool window.
        /// </summary>
        public ScaffoldItToolWindow() :
            base(null)
        {
            // Set the window title reading it from the resources.
            this.Caption = Resources.ToolWindowTitle;
            // Set the image that will appear on the tab of the window frame
            // when docked with an other window
            // The resource ID correspond to the one defined in the resx file
            // while the Index is the offset in the bitmap strip. Each image in
            // the strip being 16x16.
            this.BitmapResourceID = 301;
            this.BitmapIndex = 0;

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on 
            // the object returned by the Content property.
            _control = new FormScaffoldItConfigWrapper();
        }

        /// <summary>
        /// This property returns the handle to the user control that should
        /// be hosted in the Tool Window.
        /// </summary>
        override public IWin32Window Window
        {
            get
            {
                return (IWin32Window)_control;
            }
        }
        
        public void RefreshWindow()
        {
            _control.RefreshWindow();
        }

        internal void CloseConfig()
        {
            _control.CloseConfig();
        }
    }
}
